#include "XmlContentHandler.h"
#include <CXmlDesParser.h>
#include "IXmlParserEx.h"

XmlContentHandler::XmlContentHandler() : iXmlParser(NULL)
{
}

XmlContentHandler::~XmlContentHandler()
{
	delete iXmlParser;
	iXmlParser = NULL;

}
void XmlContentHandler::OnStartDocumentL( const RDocumentParameters& /*aDocParam*/,
        TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // Do something here when the parser at the start of the document.
        }
    else
        {
        // Do something if error happens.
        }
    }
 
void XmlContentHandler::OnEndDocumentL( TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // Do something here when the parser reaches the end of the document.
        }
    }
 
void XmlContentHandler::OnStartElementL( const RTagInfo& /*aElement*/,
        const RAttributeArray& /*aAttributes*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        
        }
    else
        {
        // Do something if error happens.
        }
    }
 
void XmlContentHandler::OnEndElementL( const RTagInfo &/*aElement*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        
        }
    else
        {
        // Do something if error happens.
        }
    }
 
void XmlContentHandler::OnContentL( const TDesC8 &/*aBytes*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnStartPrefixMappingL( const RString& /*aPrefix*/,
        const RString& /*aUri*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnEndPrefixMappingL( const RString& /*aPrefix*/,
        TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/,
        TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnSkippedEntityL( const RString& /*aName*/,
        TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnProcessingInstructionL( const TDesC8& /*aTarget*/,
        const TDesC8& /*aData*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    }
 
void XmlContentHandler::OnError( TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
        {
        // aBytes stored the value of the parsed contents.
        }
    else
        {
        // Display error messages here.
        }
    // Do something if error happens.
    }
 
TAny* XmlContentHandler::GetExtendedInterface( const TInt32 /*aUid*/ )
    {
    return 0;
    }

void XmlContentHandler::ConstructL(TInt parserType,MContentHandler& contentHandler)
	{
	if(parserType == IXmlParserEx::EXmlParser_Des)
		iXmlParser = CXmlDesParser::NewL(contentHandler);
	
	}

void XmlContentHandler::ParseXmlL(const TDesC& aDes)
	{
	iXmlParser->ParseXmlL(aDes);
	}